# -*- coding:utf-8 -*-
__author__ = 'wangjvv'

'''
date: 2021/3/10
description: 定义测试桩接口，协助部分测试用例的执行
'''
from flask import Flask,jsonify,request
from util.handleDB import handle_sql  #执行sql，并获取返回
app = Flask(__name__)  #服务名，将当前文件作为一个服务来启动


@app.route('/resource/getSubProjectId',methods=['get'])
def getSubProjectId():
    '''
    根据分期名称，获取分期Id
    '''
    try:
        stageName = request.args.get('stageName')
    except:
        return jsonify({"code":301,"message":"缺少必要参数"})
    sql = 'select id from yd_cloud.park_project_sub where project_stage_name = "{}" and project_id = 130'.format(stageName)
    res = handle_sql('yd_cloud',sql) #执行sql，获取返回
    return jsonify({"code:":200,"subProjectId":res[0]})

if __name__ == '__main__':
    app.run(port=5001, debug=True, host='0.0.0.0')  # 定义端口，调试模式打开，host设置成0.0.0.0可以让其他电脑访问本机IP
